package tj.eskhata.pos.dao.hibernate;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import tj.eskhata.pos.common.SBRate;
import tj.eskhata.pos.dao.ClPartDao;
import tj.eskhata.pos.domain.Certificate;
import tj.eskhata.pos.domain.ClPart;

public class ClPartDaoImpl extends AbstractHibernateDaoImpl<ClPart>
    implements ClPartDao {

  public ClPartDaoImpl() {
    super(ClPart.class);
  }
  
  public Date getOpDate(Long clPartId){
	  Connection con=getSession().connection();	  

	  ResultSet rs;
	  Date res = null;
	  
	  
	  try {
		CallableStatement clst= con.prepareCall("{?= call CL_PART#.GET_OP_DATE(?)}");
		
		clst.registerOutParameter(1, java.sql.Types.DATE);
		clst.setLong	(2, clPartId);				
		
		clst.execute();				//executeQuery();
		res= new Date(clst.getDate(1).getTime());
		        
	  } catch (SQLException e) {
		e.printStackTrace();
	  }
	  
	  return res;
  }
}
